package com.siwei.infoextract.rule;

import java.util.Iterator;
import java.util.List;

import com.siwei.infoextract.wrapper.parser.DomNode;

public class Rule {
	private List<Criteria> criterias;
	private Object predict;
	private int positiveNum;
	private int negativeNum;

	public List<Criteria> getCriterias() {
		return criterias;
	}
	public void setCriterias(List<Criteria> criterias) {
		this.criterias = criterias;
	}
	public Object getPredict() {
		return predict;
	}
	public void setPredict(Object predict) {
		this.predict = predict;
	}
	public int getPositiveNum() {
		return positiveNum;
	}
	public void setPositiveNum(int positiveNum) {
		this.positiveNum = positiveNum;
	}
	public int getNegativeNum() {
		return negativeNum;
	}
	public void setNegativeNum(int negativeNum) {
		this.negativeNum = negativeNum;
	}

	public boolean apply(DomNode domNode) {
		boolean allCriteriasMatched = true;
		for (Iterator<Criteria> iter = criterias.iterator(); iter.hasNext();) {
			Criteria criteria = iter.next();

			allCriteriasMatched = allCriteriasMatched & criteria.doAction(domNode);    
		}

		return allCriteriasMatched;
	}
	
}
